package com.xiyu.service.controller.admin.infra.devops;
import com.xiyu.service.vo.infra.devops.server.ServerListQueryOutput;
import com.xiyu.service.vo.infra.devops.server.ServerSingleGetOutput;
import com.xiyu.service.vo.infra.devops.server.ServerUpdateInput;
import com.xiyu.service.vo.infra.devops.server.ServerCreateInput;
import com.xiyu.service.vo.infra.devops.server.ServerPageQueryOutput;
import com.xiyu.service.vo.infra.devops.server.ServerPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.infra.devops.ServerService;
import com.xiyu.service.vo.infra.devops.server.*;

@Tag(name = "服务器管理")
@RestController
@RequestMapping("/infra/devops/server")
@Validated
public class ServerController {

    @Resource
    private ServerService serverService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询服务器")
    public CommonResult<PageResult<ServerPageQueryOutput>> pageQuery(@Valid ServerPageQueryInput inputVO) {
        return success(serverService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增服务器")
    public CommonResult<Long> create(@Valid @RequestBody ServerCreateInput inputVO) {
        return success(serverService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新服务器")
    public CommonResult<Boolean> update(@Valid @RequestBody ServerUpdateInput inputVO) {
        return success(serverService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除服务器")
    @Parameter(name = "id", description = "服务器主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(serverService.deleted(id));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个服务器")
    @Parameter(name = "id", description = "服务器主键ID", example = "")
    public CommonResult<ServerSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(serverService.singleGet(id));
    }

    @GetMapping("/list-query")
    @Operation(summary = "查询服务器")
    public CommonResult<List<ServerListQueryOutput>> listQuery() {
        return success(serverService.listQuery());
    }

}
